/* -*- coding: utf-8; tab-width: 4 -*-
vim: ts=4 noet ai */

/**
	Hide Preferences for Firefox

	Copyright © 2016  Desktopd Project

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as
	published by the Free Software Foundation, either version 3 of the
	License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

	@license GPL-3.0+
	@file
*/

'use strict';

/* Content script on about:preferences */
~function (self, top, window, parent, content, o) {
	const $id = document.getElementById.bind (document);
	const hideId = id => {try {
		$id (id).hidden = true;
	} catch (e) {}};
	const hideIdCss = id => {try {
		$id (id).style.display = 'none';
	} catch (e) {}};
	
	try {
		if (!o.general) {
			hideId ('category-general');
		}
		if (!o.search) {
			hideId ('category-search');
		}
		if (!o.content) {
			hideId ('category-content');
		}
		if (!o.applications) {
			hideId ('category-application');
		}
		if (!o.privacy) {
			hideId ('category-privacy');
		}
		if (!o.security) {
			hideId ('category-security');
		}
		if (!o.sync) {
			hideId ('category-sync');
		}
		if (!o.advanced) {
			hideId ('category-advanced');
		}
		
		if (!o['general.defaultBrowser']) {
			hideIdCss ('defaultBrowserBox');
		}
		if (!o['search.suggestions']) {
			hideId ('suggestionsInSearchFieldsCheckbox');
			hideId ('urlBarSuggestion');
			hideIdCss ('urlBarSuggestion');
		}
		
		if (!o['privacy.tracking']) {
			hideIdCss ('trackingGroup');
		}
		if (!o['privacy.history']) {
			hideIdCss ('historyGroup');
		}
		if (!o['privacy.locationBar']) {
			hideIdCss ('locationBarGroup');
		}
		if (!o['security.safeBrowsing']) {
			hideId ('enableSafeBrowsing');
			hideId ('blockDownloads');
			hideId ('blockUncommonUnwanted');
			hideId ('blockAttackSites');
			hideId ('blockWebForgeries');
		}
		if (!o['security.logins']) {
			hideIdCss ('passwordsGroup');
		}
		
		if (!o['advanced.dataChoices']) {
			hideId ('dataChoicesTab');
		}
		if (!o['advanced.network']) {
			hideId ('networkTab');
		}
		if (!o['advanced.update']) {
			hideId ('updateTab');
		}
		if (!o['advanced.cerificates']) {
			hideId ('encryptionTab');
		}
	} catch (e) {
		console.exception (e);
	}
}.call (frames, frames, frames, frames, frames, frames, self.options);


